package com.xyht.sca_s.student_manage_system.modules.employmentApplication.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.entity.SmsEmploymentApplicationProcess;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.mapper.SmsEmploymentApplicationProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class EmploymentInit {
    @Autowired
    private SmsEmploymentApplicationProcessMapper smsEmploymentApplicationProcessMapper;

    private String[] departmentNameArray = {"部门负责人", "分管院长", "院长",
            "董事长"};

    @Bean
    public void employmentApplicationInit() {
        List<SmsEmploymentApplicationProcess> processList =
                smsEmploymentApplicationProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsEmploymentApplicationProcess addProcess =
                        new SmsEmploymentApplicationProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicationEdit(false);
                addProcess.setProcessSort(sort++);
                smsEmploymentApplicationProcessMapper.insert(addProcess);
            }
        }
    }
}
